import { createStore, applyMiddleware, combineReducers } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
import { connectRouter, routerMiddleware } from 'connected-react-router';
import { createHashHistory } from "history"
import thunk from "redux-thunk";

import nativeListReducer from "./views/native-list/redux/reducer";
import nativeLogDetailReducer from "./views/native-log-detail/redux/reducer";
import webListReducer from "./views/web-list/redux/reducer";
import webLogDetailReducer from "./views/web-detail/redux/reducer";
import lagListReducer from "./views/lag-list/redux/reducer";
import launchListReducer from "./views/launch-list/redux/reducer";
import PageAnalysisListReducer from "./views/page-analysis-list/redux/reducer";
import PageH5AnalysisListReducer from "./views/page-h5-analysis-list/redux/reducer";
import OomListListReducer from "./views/oom-list/redux/reducer";
import ExceptionListReducer from "./views/exception-list/redux/reducer";
import CrashListReducer from "./views/crash-list/redux/reducer";

const composeEnhancers = composeWithDevTools({});

export const history = createHashHistory();

const createRootReducer = (history) => combineReducers({
  router: connectRouter(history),
  nativeList: nativeListReducer,
  nativeLogDetail: nativeLogDetailReducer,
  webList: webListReducer,
  webLogDetail: webLogDetailReducer,
  lagList: lagListReducer,
  launchList: launchListReducer,
  pageAnalysisList: PageAnalysisListReducer,
  pageH5AnalysisList: PageH5AnalysisListReducer,
  oomListList: OomListListReducer,
  exceptionList: ExceptionListReducer,
  crashList: CrashListReducer,
});

let store = createStore(
  createRootReducer(history),
  composeEnhancers(
    applyMiddleware(
      routerMiddleware(history),
      thunk
    )
  )
);

export default store;